<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let arr=[2,5,6,3,6]
        function handleData(a,b) {
             if(b===true ||b===undefined){
                let sum=0
                for(let i =0;i<a.length;i++){
                   sum+=a[i] 
                }
                return sum
              
            }else if (b===false){
                let sum=0
                for(let i =0;i<a.length;i++){
                   sum+=a[i] 
                }
                // let average=(sum/a.length)
                // return average
                return sum/a.length
             
            }

        }
        document.write(handleData(arr,false));
    </script>
</body>
</html>